/*
 * testDriver.java
 *
 * Created on February 16, 2007, 8:37 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package edu.byu.isys413.mystuff;

import java.util.ArrayList;

/**
 * @author abasnet
 */
public class testDriver {
    
    public testDriver(){
        
    }
    
    /** Creates a new instance of testDriver */
    public static void test(){
        
        ArrayList<customerBO> custs = null;
        customerDAO custDAO =  new customerDAO();
        membershipDAO membDAO = new membershipDAO();
        
        try{
            String id = Guid.generate();
           customerBO cusbo = new customerBO(id);
           cusbo.setAddress1("a");
           cusbo.setFirstName("b");
           cusbo.setLasttName("c");
           cusbo.setEmail("d");
           cusbo.setPhone("e");
           cusbo.setState("f");
           cusbo.setCity("g");
           cusbo.setZipcode("h");
           
           System.out.println("Name : " + cusbo.getFirstName() + " " +cusbo.getLasttName()+"\n"+
                              "Email : " + cusbo.getEmail()+"\n"+
                              "Phone : " + cusbo.getPhone()+"\n"+
                              "State : " + cusbo.getState()+"\n"       
                            );
           
           membershipBO membo = new membershipBO(Guid.generate());
           membo.setCustomerID(id);
           membo.setCrcardType("VISA");
           membo.setCrcardNumber("4234737492928734");
           membo.setCrcardExpdate("11/09");
           membo.setStartDate("02/2007");
           membo.setExpireDate("09/2009");
           
           System.out.println("Credit Card Type : " + membo.getCrcardType()+"\n"+
                               "Credit Card Number : " + membo.getCrcardNumber()+"\n"+
                                "Credit Card ExpireDate :"+ membo.getExpireDate()+"\n"+
                                "StartDate :" + membo.getStartDate()+"\n"+
                                "ExpireDate :" + membo.getExpireDate());
           
            
            custs = custDAO.readALL();
            for(int i=0; i<custs.size();i++)
                System.out.println(custs.get(i));
           
            
            /* Reads the attributes from the database and display the business object */
            customerBO custbo = custDAO.read("33015asdfn");
            System.out.println(custbo);
            
            /* saves the customerBO */
            custDAO.save(cusbo);
            
            /* finds the customer */
            String custid = custDAO.findCustomer("Anunaya Basnet","anunaya_basnet@hotmail.com");
            customerBO cusbo1 = custDAO.read(custid);
            
            /* find membership */            
            String membershipID = membDAO.findMembership("Anunaya Basnet","anunaya_basnet@hotmail.com");
            /*read membership with ID*/
            
            membershipBO membo1 = membDAO.read(membershipID);
            System.out.println("credit card type: "+membo1.getCrcardType());
            
            membDAO.save(membo);
            
            
            membershipInterestDAO membIntDAO = new membershipInterestDAO();
            
            /* reads all of the available intersts from the database and displays it*/
            ArrayList<interestBO> intrs = membIntDAO.readInterests();
            for(int i=0; i < intrs.size(); i++ )
            System.out.println("ID : "+intrs.get(i).getID()+" Description : "+intrs.get(i).getDescription());
            
            
            /* reads the interests of a member with the ID */
            ArrayList<interestBO> inters = membIntDAO.readInterests(membershipID);
            
        }catch(DataException e){}
    }
}
